define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'writerapply/index' + location.search,
                    // add_url: 'writerapply/add',
                    edit_url: 'writerapply/edit',
                    // del_url: 'writerapply/del',
                    // multi_url: 'writerapply/multi',
                    // import_url: 'writerapply/import',
                    table: 'writer_apply',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},
                        {field: 'username', title: __('用户名称')},
                        {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
                        {field: 'imgs', title: __('作品'), events: Table.api.events.image, formatter: Table.api.formatter.images, operate: false},   
                           
                        {field: 'pen_age', title: __('Pen_age'), operate: 'LIKE'},
                        // {field: 'age', title: __('Age')},
                        {field: 'age_str', title: __('Age_str')},
                        {field: 'status', title: __('状态'), searchList: {"0":__('申请中'),"1":__('通过'),"2":__('拒绝')}, formatter: Table.api.formatter.status},
                        // {field: 'refuse_msg', title: __('Refuse_msg'), operate: 'LIKE'},
                        // {field: 'reviewed_by', title: __('Reviewed_by'), operate: 'LIKE'},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                     
                        // {field: 'zsid', title: __('Zsid'), operate: 'LIKE'},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
